
#' Execute A list of ProtocolApplications
#' 
#' This actions iterates over the names of child ProtocolApplications of the
#' ProtocolApplication passed to it and creates and executes these. The parent of each
#' newly created ProtocolApplication is set to \code{protocolApplication}
#' @param protocolApplication The protocol application triggering this action.
#' @author Bastian R. Angermann
#' @export
protocolList <- function(protocolApplication)
{
    # execute
    lapply(X=protocolApplication@.childProtocolApplications, FUN=function(x,cluster) {
        oldWorkingDirectory <- getwd()
        x@cluster <- cluster
        execute(x)
        setWorkingDirectory(oldWorkingDirectory)
    },protocolApplication@cluster)
}


#' Example action that prints to stdout, logs and reports a text.
#' 
#' This action prints its text argument to stdout, writes it to to log file and adds it to the report.
#' The main purpose of this action is illustrating how to use drDobus without requiring other packages providing actions.
#' All parameters of the ProtocolApplication will be printed to stdout.
#' @param protocolApplication The protocol application triggering this action.
#' @param text A character string that will be printed, reported and logged.
#' @author Bastian R. Angermann
#' @export
printExample <- function(protocolApplication,text)
{ 
    print(paste("Action",protocolApplication@name))
    parameters <- protocolApplication@parameterValues
    if (length(parameters)>0 )
        print(unlist(parameters))
    else
        print("No Parameters defined.")
    print("Data :")
    print(unlist(text))
    submitToLog(text,"Note")
    addToReport(protocolApplication@report,as.character(text))
    return(list(main=NULL,summary=NULL,summarySemantics=NULL))
}